﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link href="../../resources/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <script src="../../resources/lib/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script src="../../resources/lib/json2.js" type="text/javascript"></script>
    <script src="../../resources/lib/ligerUI/js/core/base.js" type="text/javascript"></script>
    <link href="../../resources/lib/all.css" rel="stylesheet" />
    <script src="../../resources/lib/ligerui.all.js" type="text/javascript"></script>
    <script src="../../resources/lib/ligerUI/js/core/inject.js" type="text/javascript"></script>
    <script type="text/javascript">

        var DepartmentData = { Rows: [{ "HolidayGroup": 1, "HolidayGroupName": "节假1组" },
                                            { "HolidayGroup": 2, "HolidayGroupName": "节假2组" },
                                            { "HolidayGroup": 3, "HolidayGroupName": "节假3组" },
                                            { "HolidayGroup": 4, "HolidayGroupName": "节假4组"},
                                            { "HolidayGroup": 5, "HolidayGroupName": "节假5组"}], Total: 5 };
        var EmployeeData = { Rows: [{ "__status": null,
                                        "ID": 1,
                                        "HolidayGroup": 3,
                                        "HolidayName": "国庆节",
                                        'Text1':"无",
                                        "StartDay": new Date(),
                                        "EndtDay": new Date() },
                                        { "__status": null,
                                            "ID": 1,
                                            "HolidayGroup": 5,
                                            "HolidayName": "劳动节",
                                            'Text1':"无",
                                            "StartDay": new Date(),
                                            "EndtDay": new Date() },
                                        { "__status": null,
                                            "ID": 1,
                                            "HolidayGroup": 1,
                                            "HolidayName": "除夕节",
                                            'Text1':"无",
                                            "StartDay": new Date(),
                                            "EndtDay": new Date() }], Total: 3 };
        var DepartmentList = DepartmentData.Rows;
        $(f_initGrid);
        var manager, g;
        function f_initGrid()
        { 
           g =  manager = $("#maingrid").ligerGrid({
                columns: [
//                { display: '主键', name: 'ID', width: 50, type: 'int',frozen:true },
//                    { display: '节假日组', name: 'HolidayGroup', width: 100, isSort: false,
//                        editor: { type: 'select', data: DepartmentList, valueField: 'HolidayGroup', textField: 'HolidayGroupName' }, render: function (item)
//                    {
//                        for (var i = 0; i < DepartmentList.length; i++)
//                        {
//                            if (DepartmentList[i]['HolidayGroup'] == item.HolidayGroup)
//                                return DepartmentList[i]['HolidayGroupName']
//                        }
//                        return item.HolidayGroupName;
//                    }
//                    },
                { display: '节假日名称', name: 'HolidayName', width: 100,
                    editor: { type: 'text' }
                },
                    { display: '开始时间', name: 'StartDay', type: 'date',showTime:true ,width: 150, editor: { type: 'date',showTime:true} },
                    { display: '结束时间', name: 'EndtDay', type: 'date', showTime:true ,width: 150, editor: { type: 'date',showTime:true} },
                    { display: '备注', name: 'Text1', type: 'text',  editor: { type: 'text'} },
                    { display: '操作', isSort: false, width: 120, render: function (rowdata, rowindex, value)
                    {
                        var h = "";
                        if (!rowdata._editing)
                        {
                            h += "<a href='javascript:beginEdit(" + rowindex + ")'>修改</a> ";
                            h += "<a href='javascript:deleteRow(" + rowindex + ")'>删除</a> ";
                        }
                        else
                        {
                            h += "<a href='javascript:endEdit(" + rowindex + ")'>提交</a> ";
                            h += "<a href='javascript:cancelEdit(" + rowindex + ")'>取消</a> ";
                        }
                        return h;
                    }
                    }
                ],
                onSelectRow: function (rowdata, rowindex)
                {
                    $("#txtrowindex").val(rowindex);
                },
                enabledEdit: true, clickToEdit: false, isScroll: false,checkbox:true, rownumbers:true,
                data:EmployeeData,
                width: '100%'
            });
        }
        function beginEdit(rowid) {
            manager.beginEdit(rowid);
        }
        function cancelEdit(rowid) {
            manager.cancelEdit(rowid);
        }
        function endEdit(rowid)
        {
            manager.endEdit(rowid);
        }

        function deleteRow(rowid)
        {
            if (confirm('确定删除?'))
            {
                manager.deleteRow(rowid);
            }
        }
        function cancelAllEdit()
        {
            manager.cancelEdit();
        }
        function endAllEdit()
        {
            manager.endEdit();
        }
        var newrowid = 100;
        function addNewRow()
        {
            manager.addEditRow();
        } 
         
        function getSelected()
        { 
            var row = manager.getSelectedRow();
            if (!row) { alert('请选择行'); return; }
            alert(JSON.stringify(row));
        }
        function getData()
        { 
            var data = manager.getData();
            alert(JSON.stringify(data));
        }
    </script>
</head>
<body  style="padding:10px">
<a class="l-button" style="width:100px;float:left; margin-left:6px;" onclick="addNewRow()">添加节假日</a>

<div id="searchbar">
   &nbsp 节假日组：<input id="txtKey" type="text" />
    <input id="btnOK"  class="l-button" type="button" value="搜索" onclick="f_search()" />
</div>
 <div class="l-clear"></div>

    <div id="maingrid" style="margin-top:20px"></div> <br/>
  <div style="display:none;">
</div>
</body>
</html>
